package com.weblog.weblog.common.domain.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.weblog.weblog.common.domain.dos.ArticleContentDO;

/**
 * @author gc
 * @date 2023年10月13日 13:47
 */

public interface ArticleContentMapper extends BaseMapper<ArticleContentDO> {

    /*
     * 根据文章ID删除
     * @author gc
     * @date 2023/10/14 14:43
     * @param article
     * @return int
     */
    default int deleteByArticleId(Long article){
        return delete(Wrappers.<ArticleContentDO> lambdaQuery()
                .eq(ArticleContentDO::getArticleId,article));
    }

    /*
     * 根据文章 ID 查询
     * @author gc
     * @date 2023/10/15 21:10
     * @param articleId
     * @return com.weblog.weblog.common.domain.dos.ArticleContentDO
     */
    default ArticleContentDO selectByArticleId(Long articleId) {
        return selectOne(Wrappers.<ArticleContentDO>lambdaQuery()
                .eq(ArticleContentDO::getArticleId, articleId));
    }

    /*
     * 通过文章ID更新
     * @author gc
     * @date 2023/10/15 22:54
     * @param null
     * @return null
     */

    default int updateByArticleId(ArticleContentDO articleContentDO){
        return update(articleContentDO, Wrappers.<ArticleContentDO>lambdaQuery()
                .eq(ArticleContentDO::getArticleId,articleContentDO.getArticleId())
        );
    }
}
